home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Combine zero-offset with unit-offset arrays ?
- Date: Tue, 05 Mar 96 17:14:26 GMT
- Organization: none
- Message-ID: <826046066snz@genesis.demon.co.uk>
- References: <4hes0h$52qi@info4.rus.uni-stuttgart.de> <4hfau5INNme5@keats.ugrad.cs.ubc.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4hfau5INNme5@keats.ugrad.cs.ubc.ca>
- c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
-
- >#define fa(x) (fa[x-1])
-
- That should be (fa[(x)-1])
-
- >{
- > int foo = fa(1);
- >}
- >
- >which now gives you fa[1-1], which is *((fa) + 1 - 1).
-
- Or rather it is *(fa + (1-1))
-
- >This is defined. The
- >standard allows you generate a pointer which references one element past the
- >end of the array, thus if you put in the subscript 10, you would have
- >*((fa) + 10 - 1).
-
- That's not an ussue in this case since 1 is subtracted before the value is
- added to the pointer. So this method works for offsets other than 0 or 1.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-